<style type='text/css'>
.form-control{padding:0;}
.col-md-55, .col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12{padding:0;}
.col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9{padding-left:2px;padding-right:0;}
.form-inline .form-control{border-radius:3px;padding-left:2px;}
#tablist tr td{color:black;}
.table-striped>tbody>tr:nth-of-type(odd){background:#fff}
.table-striped>tbody>tr:nth-of-type(even){background:#cae7ea}
.table-bordered>tbody>tr>td, .table-bordered>tbody>tr>th, .table-bordered>tfoot>tr>td, .table-bordered>tfoot>tr>th, .table-bordered>thead>tr>td, .table-bordered>thead>tr>th{
  border:1px solid #000;
}
#tablist tr th{background:#000;color:#fff;}
</style>

<form class="form-inline" method="get">
<p>总求购：<span style="color: red">{$all_money.buyall}</span>求购成功：<span style="color: red">{$all_money.buyok}</span>求购中：<span style="color: red">{$all_money.buying}</span></p>
    <div class="form-group col-xs-1" style='max-width:72px;'>
        <div class="col-xs-12">
            <input class="form-control" name="id" value="{$param.id|default=''}"
                   placeholder="订单编号">
        </div>
    </div>

    <div class="form-group col-xs-2" style='max-width:155px;'>
        <div class="col-xs-12">
            <span></span><input class="form-control" name="userinfo" value="{$param.userinfo|default=''}"
                   placeholder="求购人：用户名|手机号">
        </div>
    </div>
    <div class="form-group col-xs-2">
        <div class="col-xs-12">
            {include file="public/dateRangePicker" picker-name="time_range"/}
        </div>
    </div>
    <div class="form-group col-xs-1">
        <div class="col-xs-12">
            <select class="form-control" name="status" id="status">
                <option value="">全部</option>
                {foreach $status as $sk=>$sa}
                <option value="{$sk}" {if isset($param.status) && $param.status === $sk}selected{/if}>{$sa.text}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group col-xs-1" style='max-width:155px;'>
        <div class="col-xs-12">
            <input class="form-control" name="peiduiuid" value=""
                   placeholder="出售人：用户名|手机号">
        </div>
    </div>
    <div class="form-group col-xs-2">
        <div class="col-xs-12">
            <button type="submit" class="btn btn-success">
                筛选
            </button>
        </div>
    </div>
</form>

<hr>

<table class="table table-striped table-bordered" id="tablist">
    <tr id="tabid">
        <th>编号ID</th>
        <th>购买人</th>
        <th>出售人</th>
        <th>SCB信息</th>
        <th>订单状态</th>
        <th>求购时间</th>
        <th>匹配时间</th>
        <th>支付时间</th>
        <th>支付信息</th>
        <th>确认时间</th>
        <th>操作</th>
    </tr>
    {volist name="list" id="item"}
    <tr>
        <td>
          <p>{$item.id}</p>
          <p>
            <a href="javascript:;" data-toggle="confirm" data-title="确定删除此记录？(不能恢复哦！！)" data-url="{:url('Index/delorder', ['id'=>$item.id])}" style='color:#d9534f'>
              删
            </a>
          </p>
        </td>
        <td>
            <p><label class="label label-danger">账号：{$item.b_username}</label></p>
            <p><label class="label label-info">手机号：{$item.b_selfphone}</label></p>
        </td>
        <td>
            {if !empty($item.m_username)}
            <p><label class="label label-danger">账号：{$item.m_username}</label></p>
            <p><label class="label label-success">手机号：{$item.m_selfphone}</label></p>
            {/if}
        </td>
        <td>
            <p>SCB数量：{$item.num}</p>
            <p>SCB单价：{$item.price}</p>
        </td>
        <td>
            <p><label class="label {$status[$item.status]['color']}">{$status[$item.status]['text']}</label></p>
        </td>
        <td>
            <p>{$item.create_time|show_datetime}</p>
        </td>
        <td>
            <p>{$item.match_time|show_datetime}</p>
        </td>
        <td>
            <p>{$item.pay_time|show_datetime}</p>
        </td>
        <td>
            <p>{$item.match_time|show_datetime}</p>
        </td>
        <td>
            {if $item.pay_type neq 0}
            <p>支付方式：
                {if $item.pay_type eq 1}
                微信支付
                {elseif $item.pay_type eq 2}
                支付宝支付
                {else}
                未支付
                {/if}
            </p>
            <p>支付截图：<a href="javascript:showImg('{$item.pay_img}');">查看截图</a></p>
            {/if}

        </td>
        <td>
            <div class="btn-group">
                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    操作
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                    {if $item.status eq 2 || $item.status eq 3}
                    <li>
                        <a href="javascript:void(0)" onclick="cancelMatch('{$item.id}')">
                            订单取消配对
                        </a>
                    </li>
                    {/if}
                    {if $item.status eq 3}
                    <li>
                        <a href="javascript:void(0)" onclick="sureOrder('{$item.id}')">
                            确认完成
                        </a>
                    </li>
                    {/if}
                    <li>
                        <a href="javascript:void(0)" onclick="delOrder('{$item.id}')">
                            删除订单
                        </a>
                    </li>


                    <li role="separator" class="divider"></li>
                </ul>
            </div>
        </td>

    </tr>
    {/volist}
</table>

<div class="row">
    <div class="col-xs-12" style="text-align: right;">
        {$list->render()}
    </div>
</div>
<script src="__PUBLIC__/vendors/select2/js/select2.min.js"></script>
<script type="application/javascript">
    function showImg(src) {
        layer.photos({
            photos:{
                "title": "支付截图", //相册标题
                "id": new Date().getTime(), //相册id
                "start": 0, //初始显示的图片序号，默认0
                "data": [   //相册包含的图片，数组格式
                    {
                        "alt": "支付截图",
                        "pid": 666, //图片id
                        "src": src, //原图地址
                        "thumb": "" //缩略图地址
                    }
                ]
            }
        })
    }

    function sureOrder(id) {

        layer.confirm("确定完成此订单？", function () {
            $.post("{:url('sureOrder')}", {id:id}, function (res) {
                res = JSON.parse(res)
                if(res.status == 0){
                    layer.msg(res.info);
                    setTimeout(function () {
                        location.reload();
                    }, 666);
                }else{
                    layer.alert(res.info);
                }
            });
        });
    }
    function delOrder(id) {

        layer.confirm("确定删除此订单？", function () {
            $.post("{:url('delOrder')}", {id:id}, function (res) {
                res = JSON.parse(res)
                if(res.status == 0){
                    layer.msg(res.info);
                    setTimeout(function () {
                        location.reload();
                    }, 666);
                }else{
                    layer.alert(res.info);
                }
            });
        });
    }
    function cancelMatch(id){
        layer.confirm("确定取消此订单？", function () {
            $.post("{:url('cancelMatch')}", {id:id}, function (res) {
                res = JSON.parse(res)
                if(res.status == 0){
                    layer.msg(res.info);
                    setTimeout(function () {
                        location.reload();
                    }, 666);
                }else{
                    layer.alert(res.info);
                }
            });
        });
    }
    $(function () {
        /*修改标题*/
        var title="{$templateTitle}";
        $(".dakq-nav-title").text(title);
        //获取分类
        $("#status").select2({
            placeholder: "订单状态",
            allowClear: true
        });
    });
</script>
